home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / score / score1.frm < prev    next >
Text File  |  1995-06-17  |  11KB  |  370 lines

  1. VERSION 2.00
  2. Begin Form frmScores 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "High Scores"
  6.    ClientHeight    =   3765
  7.    ClientLeft      =   2850
  8.    ClientTop       =   1515
  9.    ClientWidth     =   4230
  10.    ControlBox      =   0   'False
  11.    Height          =   4170
  12.    Icon            =   SCORE1.FRX:0000
  13.    Left            =   2790
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   3765
  18.    ScaleWidth      =   4230
  19.    Top             =   1170
  20.    Width           =   4350
  21.    Begin Timer Timer1 
  22.       Interval        =   3000
  23.       Left            =   3420
  24.       Top             =   3240
  25.    End
  26.    Begin CommandButton btnNewScore 
  27.       Caption         =   "&OK"
  28.       Height          =   375
  29.       Left            =   1500
  30.       TabIndex        =   5
  31.       Top             =   3240
  32.       Width           =   1185
  33.    End
  34.    Begin TextBox txtScore 
  35.       FontBold        =   -1  'True
  36.       FontItalic      =   0   'False
  37.       FontName        =   "MS Sans Serif"
  38.       FontSize        =   9.75
  39.       FontStrikethru  =   0   'False
  40.       FontUnderline   =   0   'False
  41.       Height          =   360
  42.       Left            =   2130
  43.       TabIndex        =   3
  44.       TabStop         =   0   'False
  45.       Text            =   "Text2"
  46.       Top             =   2820
  47.       Width           =   1965
  48.    End
  49.    Begin CommandButton btnOK 
  50.       Caption         =   "&OK"
  51.       Default         =   -1  'True
  52.       Height          =   375
  53.       Left            =   1500
  54.       TabIndex        =   4
  55.       Top             =   3480
  56.       Width           =   1185
  57.    End
  58.    Begin TextBox txtName 
  59.       FontBold        =   -1  'True
  60.       FontItalic      =   0   'False
  61.       FontName        =   "MS Sans Serif"
  62.       FontSize        =   9.75
  63.       FontStrikethru  =   0   'False
  64.       FontUnderline   =   0   'False
  65.       Height          =   360
  66.       Left            =   120
  67.       TabIndex        =   0
  68.       Text            =   "Text1"
  69.       Top             =   2820
  70.       Width           =   1905
  71.    End
  72.    Begin ListBox lstScores 
  73.       BackColor       =   &H00C0C0C0&
  74.       FontBold        =   -1  'True
  75.       FontItalic      =   0   'False
  76.       FontName        =   "MS Sans Serif"
  77.       FontSize        =   9.75
  78.       FontStrikethru  =   0   'False
  79.       FontUnderline   =   0   'False
  80.       ForeColor       =   &H000000FF&
  81.       Height          =   1230
  82.       Left            =   2160
  83.       TabIndex        =   2
  84.       TabStop         =   0   'False
  85.       Top             =   1080
  86.       Width           =   1965
  87.    End
  88.    Begin ListBox lstNames 
  89.       BackColor       =   &H00C0C0C0&
  90.       FontBold        =   -1  'True
  91.       FontItalic      =   0   'False
  92.       FontName        =   "MS Sans Serif"
  93.       FontSize        =   9.75
  94.       FontStrikethru  =   0   'False
  95.       FontUnderline   =   0   'False
  96.       ForeColor       =   &H000000FF&
  97.       Height          =   1230
  98.       Left            =   120
  99.       TabIndex        =   1
  100.       TabStop         =   0   'False
  101.       Top             =   1080
  102.       Width           =   1905
  103.    End
  104.    Begin Label Label2 
  105.       Alignment       =   2  'Center
  106.       BackStyle       =   0  'Transparent
  107.       Caption         =   "SCORES"
  108.       FontBold        =   -1  'True
  109.       FontItalic      =   0   'False
  110.       FontName        =   "MS Sans Serif"
  111.       FontSize        =   9.75
  112.       FontStrikethru  =   0   'False
  113.       FontUnderline   =   0   'False
  114.       Height          =   195
  115.       Left            =   2160
  116.       TabIndex        =   8
  117.       Top             =   840
  118.       Width           =   1875
  119.    End
  120.    Begin Label Label1 
  121.       Alignment       =   2  'Center
  122.       BackStyle       =   0  'Transparent
  123.       Caption         =   "PLAYERS"
  124.       FontBold        =   -1  'True
  125.       FontItalic      =   0   'False
  126.       FontName        =   "MS Sans Serif"
  127.       FontSize        =   9.75
  128.       FontStrikethru  =   0   'False
  129.       FontUnderline   =   0   'False
  130.       Height          =   195
  131.       Left            =   120
  132.       TabIndex        =   7
  133.       Top             =   840
  134.       Width           =   1875
  135.    End
  136.    Begin Image Image3 
  137.       Height          =   720
  138.       Left            =   0
  139.       Picture         =   SCORE1.FRX:0302
  140.       Top             =   5400
  141.       Width           =   4230
  142.    End
  143.    Begin Image Image1 
  144.       Height          =   720
  145.       Left            =   0
  146.       Picture         =   SCORE1.FRX:1E7C
  147.       Top             =   3840
  148.       Width           =   4230
  149.    End
  150.    Begin Image Image2 
  151.       Height          =   720
  152.       Left            =   0
  153.       Picture         =   SCORE1.FRX:39F6
  154.       Top             =   4620
  155.       Width           =   4230
  156.    End
  157.    Begin Label lblInfo 
  158.       Alignment       =   2  'Center
  159.       BackStyle       =   0  'Transparent
  160.       Caption         =   "Congatulations!  You've just achieved a New High Score!  Enter your name below:"
  161.       ForeColor       =   &H00FF0000&
  162.       Height          =   405
  163.       Left            =   180
  164.       TabIndex        =   6
  165.       Top             =   2400
  166.       Width           =   3765
  167.    End
  168.    Begin Image imgMain 
  169.       Height          =   720
  170.       Left            =   0
  171.       Picture         =   SCORE1.FRX:5570
  172.       Top             =   30
  173.       Width           =   4230
  174.    End
  175. End
  176. Option Explicit
  177. '------------------------------------------------------------
  178. ' SCORE1.FRM
  179. ' This form is dependent on file SCORE1.BAS.
  180. '------------------------------------------------------------
  181.  
  182. ' Windows API call used to send a message to a window.  In
  183. ' our case, we use it to send a message to a text box control
  184. ' that it should be read-only.
  185. Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
  186.  
  187. ' Constants used to make a text box read-only.
  188. Const WM_USER = &H400
  189. Const EM_SETREADONLY = (WM_USER + 31)
  190.  
  191. Sub btnNewScore_Click ()
  192. '------------------------------------------------------------
  193. ' When this button is pressed, save the new player name and
  194. ' score, then hide the text boxes and button used to enter
  195. ' the player's name, and resize the form.
  196. '------------------------------------------------------------
  197.  
  198.     ' Save all high scores back to the .INI file.
  199.     AddScoreAndSave txtName, txtScore
  200.  
  201.     DisplayScores
  202.  
  203.     SetForDisplay
  204. End Sub
  205.  
  206. Sub btnOK_Click ()
  207. '------------------------------------------------------------
  208. ' Close the frmScores window when this button is pushed.
  209. '------------------------------------------------------------
  210.  
  211.     Timer1.Enabled = False
  212.     Timer1.Interval = 0
  213.     DoEvents
  214.  
  215.     Unload Me
  216. End Sub
  217.  
  218. Sub DisplayScores ()
  219. '------------------------------------------------------------
  220. ' Display the scores and player names from the Hi() array
  221. ' into the form's list controls.
  222. '------------------------------------------------------------
  223. Dim i As Integer
  224.                       
  225.     If Num_HiScores > 0 Then
  226.     ' Empty the lists.
  227.     lstNames.Clear
  228.     lstScores.Clear
  229.  
  230.     ' Display the high scores in the list boxes.
  231.     For i = 1 To Num_HiScores
  232.         lstNames.AddItem Hi(i).Name
  233.         lstScores.AddItem Format$(Hi(i).Score)
  234.     Next
  235.     End If
  236.  
  237. End Sub
  238.  
  239. Sub Form_Load ()
  240. '------------------------------------------------------------
  241. ' When the form is loaded, center it and display the current
  242. ' high scores.
  243. '------------------------------------------------------------
  244. Dim rc As Long
  245.  
  246.     ' Center the form on the screen.
  247.     Me.Left = (Screen.Width - Me.Width) \ 2
  248.     Me.Top = (Screen.Height - Me.Height) \ 2
  249.  
  250.     Me.Caption = gGameTitle
  251.  
  252.     ' Display current high scores.
  253.     DisplayScores
  254.  
  255.     If gDisplayOnly Then
  256.     SetForDisplay
  257.     Else
  258.     
  259.     btnOK.Visible = False
  260.     btnNewScore.Default = True
  261.     
  262.     ' Clear text field to let player enter their name.
  263.     txtName = ""
  264.     txtName.MaxLength = 15
  265.     txtScore = Format$(gNewScore)
  266.     
  267.     rc = SendMessage(txtScore.hWnd, EM_